package URL;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;

public class Demo1 {
    public static void main(String[] agrs){
        try {
            URL url1=new URL("ftp://192.168.1.107/maven.txt");
            String s=url1.getFile();
            System.out.println(s);
            InputStreamReader isr=new InputStreamReader(url1.openStream(),"UTF-8");
            BufferedReader br=new BufferedReader(isr);
            File file=new File("e:\\bb.txt");
            OutputStreamWriter osw=new  OutputStreamWriter(new FileOutputStream(file),"UTF-8");
            BufferedWriter bw=new BufferedWriter(osw);
            String line=br.readLine();
            while (line!=null){
                System.out.println(line);
                bw.write(line);
                line=br.readLine();
            }
            br.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
